package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.CourseBuy;
import com.hl.sfzy.mapper.CourseBuyMapper;
import com.hl.sfzy.service.CourseBuyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CourseBuyServiceImpl implements CourseBuyService {
    @Autowired
    private CourseBuyMapper courseBuyMapper;
    @Override
    public int removeByPrimaryKey(Long id) {
        return courseBuyMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int add(CourseBuy courseBuy) {
        return courseBuyMapper.insert(courseBuy);
    }

    @Override
    public CourseBuy findByPrimaryKey(Long id) {
        return courseBuyMapper.selectByPrimaryKey(id);
    }

    @Override
    public int editByPrimaryKey(CourseBuy courseBuy) {
        return courseBuyMapper.updateByPrimaryKey(courseBuy);
    }

    @Override
    public int removeBatch(List<Long> ids) {
        return courseBuyMapper.deleteBatch(ids);
    }

    @Override
    public List<CourseBuy> find(int pageNum, int pageSize) {
        return courseBuyMapper.select(pageNum,pageSize);
    }

    @Override
    public PageInfo<CourseBuy> findByPage(int pageNum, int pageSize, CourseBuy courseBuy) {
        PageHelper.startPage(pageNum,pageSize);
        List<CourseBuy> list = courseBuyMapper.selectByPage(pageNum, pageSize, courseBuy);
        PageInfo<CourseBuy> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
